<template>
  <div class="content">
    <Header title="首页"></Header>
    <div class="swipe">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item>1</van-swipe-item>
        <van-swipe-item>2</van-swipe-item>
        <van-swipe-item>3</van-swipe-item>
        <van-swipe-item>4</van-swipe-item>
      </van-swipe>
    </div>

    <div class="sort-content">
      <ul>
        <li @click="search">
          <p><van-icon name="search" /></p>
          <span>搜索</span>
        </li>
        <li @click="notePosting">
          <p><van-icon name="notes-o" /></p>
          <span>发布</span>
        </li>
        <li>
          <p><van-icon name="edit" /></p>
          <span>留言</span>
        </li>
        <li @click="ownArticle">
          <p><van-icon name="user-o" /></p>
          <span>记录</span>
        </li>
      </ul>

      <div class="annunciate">
        <van-notice-bar left-icon="volume-o" text="无论我们能活多久，我们能够享受的只有无法分割的此刻，此外别无其他。" />
      </div>
    </div>

    <div class="recommend">
      <p>推荐博文</p>
      <p>查看更多</p>
    </div>
  </div>

  <Content isshow="true"></Content>
  <Footer></Footer>
</template>

<script setup>
import Header from '@/components/Header.vue'
import Content from '@/components/Content.vue'
import Footer from '@/components/Footer.vue'
import { useRouter } from 'vue-router';


const router = useRouter()

// 点击跳转到笔记发布
const notePosting = () => {
  router.push('/blogPublish')
}

// 点击跳转到搜索
const search = () => {
  router.push('/discover')
}

// 点击跳转到记录
const ownArticle = () => {
  let data = JSON.parse(sessionStorage.getItem('useInfo'));
  const getUserId = data.id
  console.log(getUserId);
  router.push({ path: '/ownArticle', query: {id:getUserId} })
}

</script>

<style lang="less" scoped>
.content {
  height: 100%;

  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 125px;
    text-align: center;
    background-color: #39a9ed;
  }

  .sort-content {
    height: 3rem;
    margin-top: 0.25rem;
    border: 1px solid rgb(185, 178, 178);

    ul {
      display: flex;
      justify-content: space-around;
      border-bottom: 1px solid rgb(143, 138, 138);

      li {
        padding-top: 0.25rem;
        text-align: center;
        display: flex;
        flex-direction: column;
        padding-bottom: 0.25rem;

        p {
          color: rgb(219, 59, 59);
          font-size: 1rem;
        }

        span {
          font-size: 15px;
        }
      }
    }

    .annunciate {
      // text-align: center;
      padding: 0.3rem 0;
      font-size: 0.35rem;

      span {
        text-align: center;
        width: 9rem;
        display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

    }
  }

  .recommend {
    display: flex;
    justify-content: space-between;
    font-size: 0.4rem;
    margin: 25px 0.2rem;

    p:first-child {
      font-weight: bold;
    }

    p:nth-child(2) {
      color: #aaa9a9;
    }
  }
}
</style>